package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseEvent extends SQLiteOpenHelper {

	private String tableName=null;
	public final String ID="EventID";
	public final String Title="EventTitle";
	public final String Description="EventDescription";
	public final String EventDateTime="EventEventDateTime";
	public final String Organizer="EventOrganizer";
	public final String Venue="EventVenue";
	public final String Price="EventPrice";
	public final String Agenda="EventAgenda";
	public final String Contact="EventContact";
	public final String isEvent="EventisEvent";
	
	public DatabaseEvent(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ ID + " TEXT PRIMARY KEY , "+
				  Title + " TEXT, " + Description + " TEXT, " + EventDateTime + " TEXT, " + Organizer + " TEXT, " + 
				  Venue + " TEXT, " + Price + " TEXT, " + Agenda + " TEXT, " + Contact + " TEXT, " 
				  + isEvent + " INTEGER)"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
